<!DOCTYPE html>
<html lang="en" class="page-fill">
<head>
    <meta charset="UTF-8">
    <title>OA管理後台</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> 
   <link rel="shortcut icon" href="./images/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="./css/oksub.css"/>
  
</head>
<body class="page-fill">
    <div class="page-fill" id="login">
        <form class="layui-form">    
            <div class="layui-form-item input-item">
                <label for="username">用户名</label>
                <input type="text" lay-verify="required" name="username" placeholder="请输入账号" autocomplete="off" id="username" class="layui-input">
            </div>
            <div class="layui-form-item input-item">
                <label for="password">密码</label>
                <input type="password" lay-verify="required|password" name="password" placeholder="请输入密码" autocomplete="off" id="password" class="layui-input">
            </div>          
            <div class="layui-form-item">
                <button class="layui-btn layui-block" lay-filter="login" lay-submit="">登录</button>
            </div>
            <div class="login-link">
                <a href="pages/register.html">注册</a>
                <a href="pages/forget.html">忘记密码?</a>
                <a href="pages/attendance.html">拍卡考勤界面</a>
            </div>
        </form>
    </div>
    <!--js逻辑-->
    <script src="./lib/layui/layui.js"></script>
    <script>
        layui.use(["form", "okGVerify", "okUtils", "okLayer"], function () {
            let form = layui.form;
            let $ = layui.jquery;
            let okGVerify = layui.okGVerify;
            let okUtils = layui.okUtils;
            let okLayer = layui.okLayer;

            setTimeout(function(){
                $("#password").val("");
                $("#username").val(""); 
            }, 500);
            
           
            /**
             * 初始化验证码
             */
           

            /**
             * 数据校验
             */
            form.verify({
                password: [/^[\S]{6,12}$/, "密码必须6到12位，且不能出现空格"]             
            });

            /**
             * 表单提交
             */
            form.on("submit(login)", function (data) {
                okUtils.ajax("LoginServlet?method=dologin", "get", data.field, true).done(function (response) {
                    okLayer.greenTickMsg(response.msg, function () {
                        window.location = "./index.html";
                    })
                }).fail(function (error) {
                    console.log(error)
                });
                return false;
            });
            $("#login .input-item .layui-input").parent().addClass("layui-input-active");  
           
        });
    </script>
</body>
</html>
